package com.example;

import com.example.beans.CDPlayer;
import com.example.beans.DVDPlayer;
import com.example.config.AppConfig;
import com.example.config2.Config2;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import java.io.PrintStream;

public class Application {

    public static void main(String[] args) {
        ApplicationContext context = new AnnotationConfigApplicationContext(AppConfig.class);
        CDPlayer cdPlayer = context.getBean(CDPlayer.class);
        cdPlayer.play();
        DVDPlayer dvdPlayer = context.getBean(DVDPlayer.class);
        dvdPlayer.play();
        System.out.println("musicName:" + context.getBean("musicName", String.class));
        PrintStream out = context.getBean("systemOut", PrintStream.class);
        out.println("PrintStream");

        String message = context.getBean("theMessage", String.class);
        System.out.println("message:" + message);

        Config2 config2 = context.getBean(Config2.class);
        System.out.println(config2);
    }
}
